import tempfile
import shutil
import os

path = os.path.abspath(tempfile.mkdtemp())
path_orig = "../"

# Make the installation
os.system('cd ' +path_orig+ ' && ./configure --prefix='+path +'&& make && make install')

#List of files that should be installed
files = ['cscore.py',
        'cscore',
        'ConsoleViewer.py',
        'ConsoleController.py',
        'GameManager.py',
        'Game.py',
        'Player.py',
        'Stone.py',
        'Team.py']

# List of files not installed
notinstalled = []
try:
    # Check that all files are installed in the tmp dir.
    for file in files:
        if not os.path.isfile(path+'/bin/'+file):
            notinstalled.append(file)

    # If a file has not been installed, print what file is missing.
    if not notinstalled == []:
        print "\n***Installation test failed***\n"
        print "Installation is missing files:"
        for file in notinstalled:
            print "    "+file

    else:
        print "\n***Installation test passed***\n"
finally:
    shutil.rmtree(path)
#EOF


